package yto.freemarker.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import yto.freemarker.springcloud.entity.User;

/**
 * @author dongxing
 * @create 2017-12-24 17:00
 **/
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${user.userServicePath}")
    private String userServicePath;

    @GetMapping("/simple/{id}")
    public User findById(@PathVariable Long id) {
        return restTemplate.getForObject(userServicePath + id, User.class);
    }
}
